package com.waigoulin.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @FileName AlipayConfig
 * @Description 支付宝客户端配置类
 * @Author waigoulin
 * @date 2025-07-26
 **/
@Configuration
@EnableConfigurationProperties(AlipayConfigProperties.class)
public class AlipayConfig {

    @Bean("alipayClient")
    public AlipayClient alipayClient(AlipayConfigProperties alipayConfigProperties) {
        return new DefaultAlipayClient(
                alipayConfigProperties.getGatewayUrl(),
                alipayConfigProperties.getApp_id(),
                alipayConfigProperties.getMerchant_private_key(),
                alipayConfigProperties.getFormat(),
                alipayConfigProperties.getCharset(),
                alipayConfigProperties.getAlipay_public_key(),
                alipayConfigProperties.getSign_type()
        );
    }
}


